package com.xxx.test;

import com.xxx.DAO.feedbackDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


@WebServlet("/addFeedback")
public class addFeedback extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String uName=new String(request.getParameter("uName").getBytes("iso-8859-1"),"UTF-8");
        String sex=new String(request.getParameter("sex").getBytes("iso-8859-1"),"UTF-8");
        int age = Integer.parseInt(request.getParameter("age"));
        String email=new String(request.getParameter("email").getBytes("UTF-8"),"UTF-8");
        String phone=new String(request.getParameter("phone").getBytes("UTF-8"),"UTF-8");
        String information=new String(request.getParameter("information").getBytes("iso-8859-1"),"UTF-8");
        feedbackDao dao=new feedbackDao();
        dao.add(uName,sex,age,email,phone,information);
        request.getRequestDispatcher("ContactUs.jsp?id=1").forward(request,response);
    }
}
